dragoncityfandomcom-20200223-history
User blog:Jens Ingels/The Template Guide
Note: This guide is still a work in progress. Welcome to my guide for working with templates. I will try to explain to you guys the basics of creating a wonderful template like the I template. My goal is to teach you how to use and create both switch, and database as infobox templates. This guide will probaly not be enough to explain all the functions arround the wikia. But it will do fine if you don't know anything about it. Wikia has also made a great video in one of the webinars. Intro First let me explain what a template does: A template is a page created to be included in other pages "information that you can add on 1 page so you can include it on multiple pages" The best example for this is an infobox but also for more simple templates like stub or delete. So as you see on the example the all data is listed on 1 page and that data get displayed on other pages. But that is just the beginning. If the data that you list on a template page gets changed this will also affect every page on which the template is currently active. Templates are in fact display links. But that's not its only power. Templates work in two ways. They have the ability to place data inside placeholders in their code. We know these placeholders as parameters. Last but not the least, templates support many extensions. The most popular one are ParserFunctions. This extension gives the power to change data that is pulled from the parameters. All this information looks really complex doesn't it? Don't worry, it's harder to explain in words than doing it. Source Mode Note: Before you begin to understand the basics of source mode, I highly suggest to learn the basics of the visual editor first. Here's a good video for that. Once you're settled in for visual editing you can start with switching to the source mode. If you don't know how to switch into source, I suggest you have a look at this video. It is just switching a tab in your editor (on the top right of your page). The source mode is the only mode that you can use for templates. On other pages you can choose between source and visual but I recommend to edit in source mode as much as possible. If there are too many complex codes on a page, the page will automatically switch to the source mode. Sandbox When you start creating templates it's useful to create your own personal sandbox. You can create one by visiting this special . This special link is also known as . Hint: If you are planning to create template on an regular basis I can help you with this by providing you with an update for the navbar. You can request this here. Acces&Display Note: Before starting this part I suggest you first learn how to acces the source modus. You can acces the source mode by clicking on source tab in your editor when editing an page or your sandbox. You can access a exisiting or directory from an template by adding the template name together with the template prefix. On english wikis this is the word "template". Example: Template:I. If you don't know how to mark it as a link I suggest you have a look at the basics. But since we're here to learn about templates this is the code: Template:I. At this moment you only know how to acces the template. Now I will explain how you display one. Displaying a template is in fact easier than you think. Instead of using the you will now use . Here's an example for displaying the stub template on an page: . As you can see we don't have to use the template prefix for displaying an template. We still can use it with an prefix but that's an bit stupid don't you think. Creating a Template Now you know how to acces a template, you can make you first one by posting the link in your sandbox. Simply click on the link and you will be redirect to an page that only works in source mode. There you can enter the content of the template: Now let's start with our first code. We will start easy with a simple sentence: Hi everyone, welcome to the page. Now go back to your and post the display code in the source mode. In my case this is . After saving your sandbox you now will see the displayed template: Hi everyone, welcome to the page. Use of parameters Note: In the pre boxes (source boxes) you can select all content inside it by clicking 3 times. Well, it's time to go back to our template. Ones your back out there we will learn how to use parameters. We can continue with our previous source: ---- Now we will add a placeholder, also known as an parameter marking. Let's name this one "Name". We can add this to our source by adding }. Let's replace it with : ---- So as you can see the template will currently display the parameter marking when there is no data listed. We can simply fix this by the notexist option that exist in the marking. We can do this by adding | after the parameter name inside the } marking: }} page. |- !Sandbox (page) |Hi everyone, welcome to the } page. |} ---- So we already know how to hide the marking. But in some cases we need a placeholder or default content to display if the template doesn't exist: ---- No we will go back to our sandbox and you update the template with the parameter. In my case this is . Let's give it the content "test": : ---- Let's make it a bit harder. We will replace placeholder back to the marking. So now if and only if you remove the parameter in the sandbox source this will display the fullpagename: ---- The last thing you need to know about parameters is how to enter a parameter that doens't need a name. These parameters will only work if you place them as the first parameter in the sandbox source. This invisible parameter is also known as }: ---- In order to add more no-name parameter you will have to count up like }, }, }, etc: }} }. |- !Sandbox (page) |Hi everyone, welcome to the example page, yeah testing. |} ---- Work in progress... Credits * Jens Ingels * Prajay * AvatarHA Category:Blog posts Category:Guides